package com.china08.yxyapi.api.manage.tec.office.cookbook;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.util.DateUtils;

/**
 * 获取当前星期并传输当前周信息
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class YxyTecManagerCookbookWeekCrtController {

    @RequestMapping(value = "/api_yw/manage/sch/office/cookbook/yxytecmanagecookbookweeksrh", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object precess(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> map = new HashMap<String, Object>();
        String day[] = { "", "6", "0", "1", "2", "3", "4", "5" };
        String str[] = new String[7];
        for (int i = 1; i <= 7; i++) {
            str[i - 1] = DateUtils.formatDate5(DateUtils.getThisWeek(new Date(), i));
        }
        map.put("week", str);
        map.put("index", day[DateUtils.getWeek2(new Date())]);
        return map;
    }

    /* 请求参数 */
    protected static class ReqModel extends YxyApiReqModel {

    }

    /* 响应参数 */
    protected static class RespModel extends YxyApiRespModel {
        // 日期与星期
        public Map<String, Object> map;
    }
}
